package com.zhonghui.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.mes.domain.vo.MesMaterialInspectorVo;
import com.zhonghui.response.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.mes.domain.MesMaterialInspector;
import com.zhonghui.mes.service.IMesMaterialInspectorService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 来料检验
Controller
 * 
 * @author zhonghui
 * @date 2022-05-22
 */
@RestController
@Api(tags="制造执行MES-来料检验")
@RequestMapping("/mes/inspector")
public class MesMaterialInspectorController extends BaseController
{
    @Autowired
    private IMesMaterialInspectorService mesMaterialInspectorService;

    /**
     * 查询来料检验列表
     */
    @ApiOperation("查询来料检验列表")
    @GetMapping("/list")
    public TableDataInfo<List<MesMaterialInspectorVo>> list(MesMaterialInspectorVo mesMaterialInspectorVo)
    {
        startPage();
        List<MesMaterialInspectorVo> list = mesMaterialInspectorService.selectMesMaterialInspectorList(mesMaterialInspectorVo);
        return getDataTable(list);
    }

    /**
     * 导出来料检验列表
     */
    @ApiOperation("导出来料检验列表")
    @Log(title = "来料检验", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesMaterialInspectorVo mesMaterialInspectorVo)
    {
        List<MesMaterialInspectorVo> list = mesMaterialInspectorService.selectMesMaterialInspectorList(mesMaterialInspectorVo);
        ExcelUtil<MesMaterialInspectorVo> util = new ExcelUtil<MesMaterialInspectorVo>(MesMaterialInspectorVo.class);
        util.exportExcel(response, list, "来料检验数据");
    }

    /**
     * 获取来料检验详细信息
     */
    @ApiOperation("获取来料检验详细信息")
    @GetMapping(value = "/{id}")
    public BaseResult<MesMaterialInspectorVo> getInfo(@PathVariable("id") Long id)
    {
        return BaseResult.success(mesMaterialInspectorService.selectMesMaterialInspectorById(id));
    }

    /**
     * 新增来料检验
     */
    @ApiOperation("新增来料检验")
    @Log(title = "来料检验", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResult<Integer> add(@RequestBody MesMaterialInspector mesMaterialInspector)
    {
        return BaseResult.success(mesMaterialInspectorService.insertMesMaterialInspector(mesMaterialInspector));
    }

    /**
     * 修改来料检验
     */
    @ApiOperation("修改来料检验")
    @Log(title = "来料检验", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResult<Integer> edit(@RequestBody MesMaterialInspector mesMaterialInspector)
    {
        return BaseResult.success(mesMaterialInspectorService.updateMesMaterialInspector(mesMaterialInspector));
    }

    /**
     * 删除来料检验
     */
    @ApiOperation("删除来料检验")
    @Log(title = "来料检验", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public BaseResult<Integer> remove(@PathVariable Long[] ids)
    {
        return BaseResult.success(mesMaterialInspectorService.deleteMesMaterialInspectorByIds(ids));
    }
}
